" vim: tw=0 ts=4 sw=4 noet ft=colours_bandit foldmethod=diff
" Vim colour file
" Maintainer:	A. S. Budden

hi clear
if exists("syntax_on")
  syntax reset
endif
let g:colors_name = "bandit_wst"

let ColourAssignment = {}

" Unspecified colours default to NONE, EXCEPT cterm(.*) which default to matching gui(.*)
" ctermfg will default to 'Blue' and ctermbg to 'NONE' if gui(.*) are RGB
"
" In most cases, only GUIFG is therefore important unless support for Black and White
" terminals is essential

" By default, assume the background colour is dark (changes for light backgrounds are handled later)
let ColourAssignment['Normal']          = {"GUIFG": '#dfffe3',       "GUIBG":  'grey20'}

" Comments are green
let ColourAssignment['Comment']         = {"GUIFG": 'SkyBlue'}

" These are considered to be a different sort of comment, so they get a different shade
" of green: this also allows the doxygen todo error highlighter to be able to spot
" erroneous @todo flags in non-doxygen comments (requires Doxygen Comment Matcher)
let ColourAssignment['DoxygenComment']  = {"GUIFG": '#008800'}
let ColourAssignment['DoxygenKeyword']  = {"GUIFG": '#88ffdd'}
let ColourAssignment['DoxygenLink']     = {"GUIFG": '#8888ff'}
let ColourAssignment['DoxygenTable']    = {"GUIFG": '#00bb00'}
let ColourAssignment['DoxygenTableLines']  = {"GUIFG": '#88ffdd'}

" These are PC-Lint related comments
let ColourAssignment['LintComment']     = {"GUIFG": '#00ff88'}

" Constants are shades of yellow or brown
let ColourAssignment['Constant']        = {"GUIFG": 'red2'}
let ColourAssignment['String']          = {"GUIFG": '#ffa0a0'}
let ColourAssignment['Character']       = {"GUIFG": 'DarkYellow'}

" Preprocessor directives are bold shades of blue
let ColourAssignment['PreProc']         = {"GUIFG": 'indianred',   "GUI":     'none'}
let ColourAssignment['Include']         = {"GUIFG": 'indianred',        "GUI":     'none'} " preprocessor #include
let ColourAssignment['Define']          = {"GUIFG": 'indianred',     "GUI":     'none'} " preprocessor #define
let ColourAssignment['Macro']           = {"GUIFG": 'indianred',     "GUI":     'none'} " same as Define
let ColourAssignment['PreCondit']       = {"GUIFG": 'indianred',     "GUI":     'none'} " preprocessor #if, #else, #endif, etc.

" Statements are shades of Blue
let ColourAssignment['Statement']       = {"GUIFG": 'khaki',      "GUI": 'Bold'}
let ColourAssignment['Conditional']     = {"GUIFG": 'green'} " if, then, else, endif, switch, etc.
let ColourAssignment['Repeat']          = {"GUIFG": 'OrangeRed'} " for, do, while, etc.
let ColourAssignment['Label']           = {"GUIFG": 'khaki'} " case, default, etc.
let ColourAssignment['Exception']       = {"GUIFG": '#5555AA'} " try, catch, throw

" Operators (+, =, -, % etc): not defined by default C syntax
let ColourAssignment['Operator']        = {"GUIFG": '#CCCCFF'}

" Identifiers are shades of Cyan
let ColourAssignment['Identifier']      = {"GUIFG": 'palegreen'}
let ColourAssignment['Function']        = {"GUIFG": 'palegreen'}
let ColourAssignment['Method']          = {"GUIFG": '#009966'}

" Special additions created by mktypes.py are shades of Purple or Grey
let ColourAssignment['Class']           = {"GUIFG": 'Purple'}
let ColourAssignment['DefinedName']     = {"GUIFG": '#ee82ee'}
let ColourAssignment['EnumerationValue']= {"GUIFG": '#c000c0'}
let ColourAssignment['EnumerationName'] = {"GUIFG": '#ff22ff'}
let ColourAssignment['Member']          = {"GUIFG": '#8da712'}
let ColourAssignment['Union']           = {"GUIFG": 'Grey'}
let ColourAssignment['GlobalVariable']  = {"GUIFG": 'magenta'}
let ColourAssignment['LocalVariable']   = {"GUIFG": '#C8E3FF'}
let ColourAssignment['GlobalConstant']  = {"GUIFG": '#bbbb00'}

" Types/storage classes etc are shades of orangey-red
let ColourAssignment['Type']            = {"GUIFG": 'darkkhaki',   "GUI": "Bold"}
let ColourAssignment['StorageClass']    = {"GUIFG": '#ff4040'} " static, register, volatile, etc.
let ColourAssignment['Structure']       = {"GUIFG": 'lightgreen'} " struct, union, enum, etc.

" Special Stuff
let ColourAssignment['Special']         = {"GUIFG": 'navajowhite'}
let ColourAssignment['SpecialChar']     = {"GUIFG": 'navajowhite'}     " special character in a constant
let ColourAssignment['SpecialKey']      = {"GUIFG": 'yellowgreen'}     " special highlighting for 'listchars' etc
let ColourAssignment['NonText']         = {"GUIFG": 'LightBlue',    "GUIBG": 'grey30'}     " special highlighting for 'listchars' etc
let ColourAssignment['MatchParen']      = {"GUI":   'Underline',   "GUIFG": "#dfffdf",     "GUIBG": 'grey30'}   " Highlighting of matching parentheses

" Errors
let ColourAssignment['Error']           = {"GUIFG": 'White',       "GUIBG":   'Red',       "TERM":  'Reverse'}
let ColourAssignment['NonIndentTabError']={"GUISP": '#FFAA00',     "GUI":   'undercurl',   "CTERMBG": 'Red'}

" Stuff needing doing
let ColourAssignment['Todo']            = {"GUIFG": 'orangered',        "GUIBG":   'yellow2',    "TERM":  'Standout'}

" Folding
let ColourAssignment['FoldColumn']      = {"GUIFG": 'tan',    "GUIBG":   'grey30'}

" Popup Menu
let ColourAssignment['Pmenu']           = {"GUIFG": '#442206',     "GUIBG": '#ffff77',     "CTERMFG": "Black",   "CTERMBG": "Yellow"}

" Line Numbering
let ColourAssignment['LineNr']          = {"GUIFG": 'yellow',      "GUIBG": '#3a3a3a'}

" Status Lines
let ColourAssignment['StatusLine']      = {"GUIFG": 'Black',       "GUIBG": '#c2bfa5'}
let ColourAssignment['StatusLineNC']    = {"GUIFG": 'grey50',       "GUIBG": '#c2bfa5'}

" Vertical Splits
let ColourAssignment['VertSplit']       = {"GUIFG": 'grey50',       "GUIBG": "#c2bfa5",	    "GUI": "none"}

" Signs Column
let ColourAssignment['SignColumn']      = {"GUIBG": '#222222'}

" Text Titles
let ColourAssignment['Title']           = {"GUIFG": 'indianred',        "GUI": "Bold"}
let ColourAssignment['htmlH1']          = {"GUIFG": 'Blue'}
let ColourAssignment['htmlH2']          = {"GUIFG": '#8888FF'}
let ColourAssignment['htmlH3']          = {"GUIFG": '#9999DD'}
let ColourAssignment['htmlH4']          = {"GUIFG": '#5555AA'}
let ColourAssignment['htmlH5']          = {"GUIFG": '#8888AA'}
let ColourAssignment['htmlH6']          = {"GUIFG": '#888888'}


" Delimiters
let ColourAssignment['Delimiter']       = {"GUIFG": 'Cyan',	"GUI": 'Bold'}
" Rainbow highlighting of nested brackets
" TODO: Find the closest ctermfg match to the various guifg colours
let ColourAssignment['hlLevel0']        = {"GUIFG": 'DarkCyan'}
let ColourAssignment['hlLevel1']        = {"GUIFG": '#bfbf00'}
let ColourAssignment['hlLevel2']        = {"GUIFG": '#990033'}
let ColourAssignment['hlLevel3']        = {"GUIFG": '#334488'}
let ColourAssignment['hlLevel4']        = {"GUIFG": '#996622'}
let ColourAssignment['hlLevel5']        = {"GUIFG": '#ff2222'}
let ColourAssignment['hlLevel6']        = {"GUIFG": '#4444ff'}
let ColourAssignment['hlLevel7']        = {"GUIFG": '#ffff44'}
let ColourAssignment['hlLevel8']        = {"GUIFG": '#96cdcd'}
let ColourAssignment['hlLevel9']        = {"GUIFG": '#698b22'}
" Stop rainbow.vim from overwriting these colours (requires modifications to rainbow.vim v2a
let g:rainbow_delimiter_colours_defined = 1

" ========================================================================
" Other available highlighting groups are listed at the bottom of the file
" Light Background stuff is below the MakeDarker function
" ========================================================================

function! s:MakeDarker(rgb)
	let rgbSplitter = '^#\(\x\{2}\)\(\x\{2}\)\(\x\{2}\)$'
	let matches = matchlist(a:rgb, rgbSplitter)
	if empty(matches)
		return a:rgb
	endif
	let Red = matches[1]
	let Green = matches[2]
	let Blue = matches[3]
	let percentage = 70
	let darken_above_here = 0x7f*3

	let Red = str2nr(Red, 16)
	let Green = str2nr(Green, 16)
	let Blue = str2nr(Blue, 16)
	if (Red+Green+Blue) < darken_above_here
		return a:rgb
	endif

	let Red = Red*percentage/100
	let Green = Green*percentage/100
	let Blue = Blue*percentage/100

	let result = printf("#%02x%02x%02x", Red, Green, Blue)

	return result
	
endfunction


" Now change those that are different for the light background
if &background == 'light'
	" Automatically change any LightXxxxx Colours to DarkXxxxx
	for s:group in keys(ColourAssignment)
		for s:Component in keys(ColourAssignment[s:group])
			if match(ColourAssignment[s:group][s:Component], 'Light') == 0
				let ColourAssignment[s:group][s:Component] = 'Dark'.ColourAssignment[s:group][s:Component][5:]
			elseif match(ColourAssignment[s:group][s:Component], '^#\x\{6}$') != -1
				let ColourAssignment[s:group][s:Component] = s:MakeDarker(ColourAssignment[s:group][s:Component])
			endif
		endfor
	endfor

	" Now add manual alterations
	let ColourAssignment['Normal']              = {"GUIFG": 'Black',     "GUIBG": 'White'}
	let ColourAssignment['Comment']["GUIFG"]    = 'DarkGreen'
	let ColourAssignment['String']["GUIFG"]     = '#663300'
	let ColourAssignment['String']["CTERMFG"]   = 'DarkYellow'
	let ColourAssignment['Union']["GUIFG"]      = 'DarkGrey'
	let ColourAssignment['Identifier']["GUIFG"] = 'Blue'
	let ColourAssignment['Operator']["GUIFG"]   = '#222288'
	let ColourAssignment['LineNr']["GUIBG"]     = 'Grey'
	let ColourAssignment['StatusLine']["GUIBG"] = 'Black'
	let ColourAssignment['StatusLine']["GUIFG"] = 'White'
	let ColourAssignment['SignColumn']["GUIBG"] = "LightGrey"
	let ColourAssignment['SpecialKey']["GUIFG"] = '#AAAAAA'
	let ColourAssignment['NonText']["GUIFG"]    = '#AAAAAA'
endif

hi Ignore ctermfg=DarkGrey guifg=grey40

" Unless there is a need to change the links at the bottom, don't change anything below this line

let s:colours = {}
let valid_cterm_colours = 
			\ [
			\     'Black', 'DarkBlue', 'DarkGreen', 'DarkCyan',
			\     'DarkRed', 'DarkMagenta', 'Brown', 'DarkYellow',
			\     'LightGray', 'LightGrey', 'Gray', 'Grey',
			\     'DarkGray', 'DarkGrey', 'Blue', 'LightBlue',
			\     'Green', 'LightGreen', 'Cyan', 'LightCyan',
			\     'Red', 'LightRed', 'Magenta', 'LightMagenta',
			\     'Yellow', 'LightYellow', 'White',
			\ ]
for key in keys(ColourAssignment)
	let s:colours = ColourAssignment[key]
	if has_key(s:colours, 'TERM')
		let term = s:colours['TERM']
	else
		let term = 'NONE'
	endif
	if has_key(s:colours, 'GUI')
		let gui = s:colours['GUI']
	else
		let gui='NONE'
	endif
	if has_key(s:colours, 'GUIFG')
		let guifg = s:colours['GUIFG']
	else
		let guifg='NONE'
	endif
	if has_key(s:colours, 'GUIBG')
		let guibg = s:colours['GUIBG']
	else
		let guibg='NONE'
	endif
	if has_key(s:colours, 'CTERM')
		let cterm = s:colours['CTERM']
	else
		let cterm=gui
	endif
	if has_key(s:colours, 'CTERMFG')
		let ctermfg = s:colours['CTERMFG']
	else
		if index(valid_cterm_colours, guifg) != -1
			let ctermfg=guifg
		else
			let ctermfg='White'
		endif
	endif
	if has_key(s:colours, 'CTERMBG')
		let ctermbg = s:colours['CTERMBG']
	else
		if index(valid_cterm_colours, guibg) != -1
			let ctermbg=guibg
		else
			let ctermbg='NONE'
		endif
	endif
	if has_key(s:colours, 'GUISP')
		let guisp = s:colours['GUISP']
	else
		let guisp='NONE'
	endif

	if key =~ '^\k*$'
		execute "hi ".key." term=".term." cterm=".cterm." gui=".gui." ctermfg=".ctermfg." guifg=".guifg." ctermbg=".ctermbg." guibg=".guibg." guisp=".guisp
	endif
endfor

" hi! link MoreMsg        Comment
hi  MoreMsg	guifg=SeaGreen
hi! link ErrorMsg       Visual
" hi! link WarningMsg     ErrorMsg
hi WarningMsg	guifg=salmon
" hi! link Question       Comment
hi Question	guifg=springgreen
hi  link Number         Constant
hi  link Boolean        Number
hi  link Float          Number
hi  link Keyword        Statement
hi  link Typedef        Type
hi  link SpecialComment Special
hi  link Debug          Special

hi link javaParen  hlLevel0
hi link javaParen1 hlLevel1
hi link javaParen2 hlLevel2

" For reference, roughly equivalent syntax highlighting in diffuse
" (http://diffuse.sourceforge.net)
" This is for C++ syntax:
"
" # colours
" colour c++_comment 0.0 0.5 0.0
" colour c++_fixme 0.5 0.5 0.0
" colour c++_keyword 0.2 0.2 0.7
" colour c++_type 0.7 0.3 0.0
" colour c++_cpp 0.0 0.0 0.0
" colour c++_cppkeyword 0.4 0.4 0.7
" colour c++_literal 0.7 0.7 0.3
" colour c++_string 0.4 0.2 0.0
" colour c++_escapedchar 0.7 0.0 0.0
" colour c++_punctuation 0.1 0.1 0.5

highlight Normal ctermfg=194 ctermbg=236
highlight Comment  ctermfg=117
highlight DoxygenComment  ctermfg=28
highlight DoxygenKeyword  ctermfg=122
highlight DoxygenLink  ctermfg=105
highlight DoxygenTable  ctermfg=34
highlight DoxygenTableLines  ctermfg=122
highlight LintComment  ctermfg=48
highlight Constant  ctermfg=196
highlight String  ctermfg=217
highlight Character  ctermfg=142
highlight PreProc  ctermfg=167 cterm=NONE
highlight Include  ctermfg=167 cterm=NONE
highlight Define  ctermfg=167 cterm=NONE
highlight Macro  ctermfg=167 cterm=NONE
highlight PreCondit  ctermfg=167 cterm=NONE
highlight Statement  ctermfg=186 cterm=bold
highlight Conditional  ctermfg=46
highlight Repeat  ctermfg=202
highlight Label  ctermfg=186
highlight Exception  ctermfg=61
highlight Operator  ctermfg=189
highlight Identifier  ctermfg=120
highlight Function  ctermfg=120
highlight Method  ctermfg=29
highlight Class  ctermfg=129
highlight DefinedName  ctermfg=213
highlight EnumerationValue  ctermfg=127
highlight EnumerationName  ctermfg=201
highlight Member  ctermfg=106
highlight Union  ctermfg=250
highlight GlobalVariable  ctermfg=201
highlight LocalVariable  ctermfg=153
highlight GlobalConstant  ctermfg=142
highlight Type  ctermfg=143 cterm=bold
highlight StorageClass  ctermfg=203
highlight Structure  ctermfg=120
highlight Special  ctermfg=223
highlight SpecialChar  ctermfg=223
highlight SpecialKey  ctermfg=112
highlight NonText  ctermfg=152 ctermbg=239
highlight MatchParen  ctermfg=194 ctermbg=239 cterm=underline
highlight Error  ctermfg=231 ctermbg=196
highlight NonIndentTabError  cterm=undercurl
highlight Todo  ctermfg=202 ctermbg=226
highlight FoldColumn  ctermfg=180 ctermbg=239
highlight Pmenu  ctermfg=52 ctermbg=228
highlight LineNr  ctermfg=226 ctermbg=237
highlight StatusLine  ctermfg=16 ctermbg=144
highlight StatusLineNC  ctermfg=244 ctermbg=144
highlight VertSplit  ctermfg=244 ctermbg=144 cterm=NONE
highlight SignColumn  ctermbg=235
highlight Title  ctermfg=167 cterm=bold
highlight htmlH1    ctermfg=21
highlight htmlH2    ctermfg=105 
highlight htmlH3    ctermfg=104
highlight htmlH4    ctermfg=61
highlight htmlH5    ctermfg=103
highlight htmlH6    ctermfg=102
highlight Delimiter  ctermfg=51 cterm=bold
highlight hlLevel0  ctermfg=30
highlight hlLevel1  ctermfg=142
highlight hlLevel2  ctermfg=125
highlight hlLevel3  ctermfg=61
highlight hlLevel4  ctermfg=94
highlight hlLevel5  ctermfg=196
highlight hlLevel6  ctermfg=63
highlight hlLevel7  ctermfg=227
highlight hlLevel8  ctermfg=116
highlight hlLevel9  ctermfg=64 

highlight IncSearch guifg=slategrey guibg=khaki ctermfg=67 ctermbg=186
highlight ModeMsg guifg=goldenrod ctermfg=178
highlight Folded guifg=gold guibg=grey30 ctermfg=220 ctermbg=239
highlight Cursor guifg=khaki guibg=indianred ctermfg=186 ctermbg=167
highlight Search guifg=black guibg=#efcb62 ctermfg=16 ctermbg=221
highlight Visual guifg=khaki guibg=olivedrab gui=NONE ctermfg=186 ctermbg=64 cterm=NONE
highlight WarningMsg guifg=salmon ctermfg=210

" xiao_kuohao & da_kuohao
highlight c_dakuohao guifg=#d65f7f gui=bold ctermfg=168 cterm=bold
highlight c_xiaokuohao guifg=#a38a7f gui=bold ctermfg=138 cterm=bold

" Math Operator
hi cMathOperator            guifg=#3EFFE2	ctermfg=50
hi cPointerOperator         guifg=#3EFFE2	ctermfg=50
hi cLogicalOperator         guifg=#3EFFE2	ctermfg=50
hi cBinaryOperator          guifg=#3EFFE2	ctermfg=50
hi cBinaryOperatorError     guifg=#3EFFE2	ctermfg=50
hi cLogicalOperator         guifg=#3EFFE2	ctermfg=50
hi cLogicalOperatorError    guifg=#3EFFE2	ctermfg=50


hi cFunction	gui=NONE	guifg=#B5A1FF	ctermfg=147 cterm=NONE
hi c99Function	gui=bold	guifg=#7E59FF 	 ctermfg=99 cterm=bold

" hi Number       guifg=magenta		ctermfg=Red
" highlight String
" highlight Structure
" highlight Conditional
" highlight Repeat


" color terminal definitions
" highlight SpecialKey
highlight NonText cterm=bold
" highlight Directory
highlight ErrorMsg cterm=bold
highlight IncSearch cterm=NONE
highlight Search cterm=NONE
" highlight MoreMsg
highlight ModeMsg cterm=NONE
" highlight LineNr
" highlight Question
" highlight StatusLine cterm=bold,reverse
" highlight StatusLineNC cterm=reverse
highlight VertSplit cterm=reverse
" highlight Title
highlight Visual cterm=reverse
highlight VisualNOS cterm=bold,underline
" highlight WarningMsg
" highlight WildMenu
" highlight Folded
" highlight FoldColumn
" highlight DiffAdd
" highlight DiffChange
highlight DiffDelete cterm=bold
highlight DiffText cterm=bold
" highlight Comment
" highlight Constant
" highlight Special
" highlight Identifier
" highlight Statement
" highlight PreProc
" highlight Todo
" highlight Type
highlight Underlined cterm=underline
highlight Ignore cterm=bold
" highlight Ignore
highlight Error cterm=bold

" For mark.vim plugin
" highlight def MarkWord1  ctermbg=Cyan     ctermfg=Black  guibg=#8CCBEA    guifg=Black
" highlight def MarkWord2  ctermbg=Green    ctermfg=Black  guibg=#A4E57E    guifg=Black
" highlight def MarkWord3  ctermbg=Yellow   ctermfg=Black  guibg=#FFDB72    guifg=Black
" highlight def MarkWord4  ctermbg=Red      ctermfg=Black  guibg=#FF7272    guifg=Black
" highlight def MarkWord5  ctermbg=Magenta  ctermfg=Black  guibg=#FFB3FF    guifg=Black
" highlight def MarkWord6  ctermbg=Blue     ctermfg=Black  guibg=#9999FF    guifg=Black
highlight MarkWord1 guifg=black guibg=#8ccbea ctermfg=16 ctermbg=117
highlight MarkWord2 guifg=black guibg=#a4e57e ctermfg=16 ctermbg=113
highlight MarkWord3 guifg=black guibg=#ff7272 ctermfg=16 ctermbg=203
highlight MarkWord4 guifg=black guibg=#ffb3ff ctermfg=16 ctermbg=219
highlight MarkWord5 guifg=black guibg=#9999ff ctermfg=16 ctermbg=105
highlight MarkWord6 guifg=black guibg=#ffdb72 ctermfg=16 ctermbg=221

